import math


# 用类封装一个Math类, 实现加, 减, 乘, 除, 幂, 开方
class MyMatch:
    # 加法
    def add(self, x, y):
        return x + y

    # 减法
    def reduce(self, x, y):
        return x - y

    # 乘法
    def mul(self, x, y):
        return x * y

    # 乘方
    def power(self, x, y):
        return x ** y

    # 除法
    def division(self, x, y):
        if y == 0:
            return False
        return x / y

    # 整除
    def divisible(self, x, y):
        if y == 0:
            return False
        return x // y

    # 取余
    def surplus(self, x, y):
        if y == 0:
            return False
        return x % y

    # 开方
    def evolution(self, x):
        return math.sqrt(x)


# 自由课题, 按照自己的想法, 将身边的事物抽象成类, 并创建多个实例.
class Dog(object):
    def __init__(self, name):
        self.name = name

    def run(self):
        return f'{self.name} 的能跑'

    def attr(self):
        return f'{self.name} 的特性'


# 牧羊犬
class MuDog(Dog):

    def fesc(self):
        return f'{self.name} 能放羊'

    def attr(self):
        return f'{self.name} 的自己特性'


class TaiDiDog(Dog):

    def attr(self):
        return f'{self.name} 的自己特性'


if __name__ == '__main__':
    match = MyMatch()
    print(match.add(1, 2))

    print('-------------------')
    dog = Dog('狗类')
    print(dog.run())
    print(dog.attr())

    mu_dog = MuDog('牧羊犬')
    print(mu_dog.run())
    print(mu_dog.attr())

    taidi_dog = TaiDiDog('泰迪')
    print(taidi_dog.run())
    print(taidi_dog.attr())
